home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270 tools
/
genktab.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-01-21
|
4KB
|
144 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#include <stdio.h>
unsigned char codeline[128];
unsigned char typebuff[256];
unsigned char databuff[256];
unsigned char aplbuff[256];
unsigned char hexbuff[8];
unsigned char outline[128];
main()
{
int i, j, index, i1, i2, lnum;
char * rc;
unsigned char s1[64];
unsigned char s2[64];
unsigned char s3[64];
unsigned char type, val, apl, ge;
FILE *infile, *outfile, *namefile;
char * myfgets(char *, int, FILE *);
for (i=0; i < 256; i++)
typebuff[i] = databuff[i] = aplbuff[i] = 0;
infile = fopen("keycodes.memo", "r");
if (infile == 0) {
printf("Error opening keycodes.memo\n");
return;
}
namefile = fopen("kbnames.new", "w");
if (namefile == 0) {
printf("Error creating kbnames.new\n");
return;
}
fprintf(namefile, "static unsigned char * namelist[] = {\n");
rc = fgets(codeline, 128, infile); /* skip first line */
rc = fgets(codeline, 128, infile);
lnum = 2;
index = 0;
while (rc != 0) {
sscanf(codeline,
"%s %x %x %s %s",
s1, &i1, &i2, s2, s3);
type = s1[0];
val = i1;
apl = i2;
ge = s2[0];
fprintf(namefile, "\t/* %03d */\t\"%s\",\n", index, s3);
switch(type) {
case 'D': typebuff[index] = 1;
if (ge == 'Y') typebuff[index] += 0x80;
break;
case 'L': typebuff[index] = 0x41; /* caps lock works */
break;
case 'A': typebuff[index] = 2;
break;
case 'C': typebuff[index] = 3;
break;
default: break;
}
databuff[index] = val;
aplbuff[index] = apl;
rc = fgets(codeline, 128, infile);
lnum++;
index++;
}
fprintf(namefile, "\t};");
fclose(namefile);
outfile = fopen("kbtables.new", "w");
if (outfile == 0) {
printf("Error creating kbtables.c\n");
return;
}
fputs("static unsigned char kbtyp[] = {\n",outfile);
for (i=0; i < 256; i+= 8) {
strcpy(outline," ");
for (j=0; j < 8; j++) {
sprintf(hexbuff,"0x%02x,",typebuff[i+j]);
strcat(outline,hexbuff);
}
strcat(outline,"\n");
fputs(outline,outfile);
}
fputs("static unsigned char kbstd[] = {\n",outfile);
for (i=0; i < 256; i+= 8) {
strcpy(outline," ");
for (j=0; j < 8; j++) {
sprintf(hexbuff,"0x%02x,",databuff[i+j]);
strcat(outline,hexbuff);
}
strcat(outline,"\n");
fputs(outline,outfile);
}
fputs("static unsigned char kbapl[] = {\n",outfile);
for (i=0; i < 256; i+= 8) {
strcpy(outline," ");
for (j=0; j < 8; j++) {
sprintf(hexbuff,"0x%02x,",aplbuff[i+j]);
strcat(outline,hexbuff);
}
strcat(outline,"\n");
fputs(outline,outfile);
}
fclose(outfile);
}